﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        var time = new Date();
        var day = ('0' + time.getDate()).slice(-2);
        var month = ('0' + (time.getMonth() + 1)).slice(-2);
        var today = time.getFullYear() + '-' + month + '-' + day;
        $('#startDate').val(today);
        $('#endDate').val(today);

        $('#startDate').datetimepicker({
            language: 'zh-CN',
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            minView: 2,
            forceParse: 0
        });

        $('#endDate').datetimepicker({
            language: 'zh-CN',
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            minView: 2,
            forceParse: 0
        });

        gridList();
        $("#gridList").jqGrid('setLabel', 'rn', '序号', { 'text-align': 'center', 'vertical-align': 'middle' });
    })
    function gridList() {
        var $gridList = $("#gridList");
        console.log($("#startDate").val());
        console.log($("#endDate").val());
        $gridList.dataGrid({
            url: "/Gas/DiningRecord/GetGridJson",
            height: $(window).height() - 96,
            postData: { 'StartDate': $("#startDate").val(), 'EndDate': $("#endDate").val() },
            colModel: [
                { label: "主键", name: "F_Id", hidden: true, key: true },
                { label: '姓名', name: 'RName', width: 50, align: 'left' },
                { label: '身份证号', name: 'IDNumber', width: 150, align: 'left' },
                { label: '刷卡时间', name: 'DiningTime', width: 150, align: 'left' },
                
            ],
            pager: "#gridPager",
            sortname: 'DiningTime desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            var startDt = $("#startDate").val();
            var endDt = $("#endDate").val();
            $gridList.jqGrid('setGridParam', {
                postData: { RName: $("#txtRName").val(), IDNumber: $("#txtIDNumber").val(), StartDate: startDt, EndDate: endDt },
            }).trigger('reloadGrid');
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增居民",
            url: "/Gas/Resident/Form",
            width: "550px",
            height: "570px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }//btn: null
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: "Form",
            title: "修改居民",
            url: "/Gas/Resident/Form?keyValue=" + keyValue,
            width: "550px",
            height: "570px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/Gas/Resident/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().F_Id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: "Details",
            title: "查看居民",
            url: "/Gas/Resident/Details?keyValue=" + keyValue,
            width: "550px",
            height: "620px",
            btn: null,
        });
    }
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txtRName" type="text" class="form-control" placeholder="姓名" style="width: 150px;">&nbsp;&nbsp;&nbsp;&nbsp;
                        <input id="txtIDNumber" type="text" class="form-control" placeholder="身份证号" style="width: 200px;">
                        <input type="text" value="" id="startDate" class="form-control" data-date-format="yyyy-mm-dd" style="width: 150px;">
                        <input type="text" value="" id="endDate" class="form-control" data-date-format="yyyy-mm-dd" style="width: 150px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
